home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / tclMotif-1.4 / doc / examples / list.tcl < prev    next >
Text File  |  1995-06-29  |  3KB  |  99 lines

  1. #! moat
  2. #
  3. # list.tcl : a simple list demo.
  4. #
  5.  
  6. # The toplevel bulletin board
  7.  
  8. xtAppInitialize
  9. xmBulletinBoard .top managed
  10.  
  11. #----------------------------------------------
  12. # The mode radio selector
  13. xmRowColumn .top.mode managed -x 200 -y 10
  14.  
  15. xmToggleButton .top.mode.single managed \
  16.     -labelString "single selection mode" -selectColor red
  17. xmToggleButton .top.mode.multiple managed \
  18.     -labelString "multiple selection mode" -selectColor red
  19. xmToggleButton .top.mode.extended managed \
  20.     -labelString "extended selection mode" -selectColor red
  21. xmToggleButton .top.mode.browse managed \
  22.     -labelString "browse selection mode" -selectColor red
  23.  
  24. .top.mode setValues \
  25.     -radioBehavior True \
  26.     -radioAlwaysOne True
  27.  
  28. .top.mode.single disarmCallback {
  29.     .top.list setValues -selectionPolicy single_select
  30. }
  31. .top.mode.multiple disarmCallback {
  32.     .top.list setValues -selectionPolicy multiple_select
  33. }
  34. .top.mode.extended disarmCallback {
  35.     .top.list setValues -selectionPolicy extended_select
  36. }
  37. .top.mode.browse disarmCallback {
  38.     .top.list setValues -selectionPolicy browse_select
  39. }
  40.  
  41. #----------------------------------------------
  42. # The list widget
  43.  
  44. xmScrolledList .top.list managed \
  45.     -x 10 -y 10 \
  46.     -width 180 -visibleItemCount 5 \
  47.     -listSizePolicy constant
  48.  
  49. .top.list singleSelectionCallback {
  50.     puts stdout "single selection of item %item at position %item_position"
  51. }
  52. .top.list multipleSelectionCallback {
  53.     puts stdout "multiple selection of item %item at position %item_position"
  54. }
  55. .top.list extendedSelectionCallback {
  56.     puts stdout "extended selection of item %item at position %item_position"
  57. }
  58. .top.list browseSelectionCallback {
  59.     puts stdout "browse selection of item %item at position %item_position"
  60. }
  61. .top.list defaultActionCallback {
  62.     puts stdout "Default action called on item %item at position %item_position"
  63. }
  64.  
  65. #----------------------------------------------
  66. # The button to edit the list contens
  67. xmRowColumn .top.edit managed \
  68.     -x 300 -y 150 \
  69.     -orientation horizontal
  70. xmPushButton .top.edit.add managed -labelString "Add"
  71. xmPushButton .top.edit.delete managed -labelString "Delete"
  72. xmPushButton .top.edit.quit managed -labelString "Quit" \
  73.     -background NavyBlue
  74. xmTextField  .top.item managed \
  75.     -x 10 -y 150 -width 280
  76.  
  77. .top.edit.quit activateCallback {exit 0}
  78. .top.edit.add  activateCallback {
  79.     .top.item getValues -text it
  80.     .top.list addItem $it 0
  81. }
  82. .top.edit.delete activateCallback {
  83.     .top.list getValues -selectedItems del_list
  84.     foreach item [split $del_list ","] {
  85.         .top.list deleteItem [string trim $item " "]
  86.     }
  87. }
  88.  
  89. #----------------------------------------------
  90. # List insertion : the first elements
  91. .top.list addItem Un 1000
  92. .top.list addItem Deux 1000
  93. .top.list addItem Trois 1000
  94.  
  95.  
  96. #----------------------------------------------
  97. . realizeWidget
  98. . mainLoop
  99.